home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0118_Grabbing Pixel Color.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  595b  |  24 lines

  1. {
  2.  GK> I have a slight problem.  I have written a program that runs in
  3.  GK> graphics mode ($13).  I use the following routine to get what
  4.  GK> colour is at that pixel :-
  5.  GK>     PixelColor := MEM[$A000:X + (Y*320)];
  6.  GK> This works fine, but it is rather slow.  I was wondering if
  7.  GK> anybody knew how to do this faster?
  8. }
  9.  
  10.    Function PixColor(x, y : Word) : Byte; Assembler;
  11.     Asm
  12.      push  ds
  13.      mov   ax,0a000h
  14.      mov   ds,ax
  15.      mov   ax,y
  16.      shl   ax,6
  17.      mov   si,ax
  18.      shl   ax,2
  19.      add   si,ax
  20.      add   si,x
  21.      lodsb
  22.      pop   ds
  23.     End;
  24.